package com.woniuxy.controller;

import com.woniuxy.beans.pojo.User;
import com.woniuxy.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpServletRequest;

@Controller
public class LoginController {
    @Autowired
    private UserService userService;
    @RequestMapping(value = "login.do")
    public String login(User user, HttpServletRequest request){
        System.out.println("**********************");
        User result=userService.login(user.getLoginname(),user.getPassword());
        if(result==null){
            request.setAttribute("loginError","用户名或密码有误！");
            return "login";
        }
        return "redirect:/sys/index.do";
    }
}
